package com.jwthhealth_pub.old.report.view.adapter;

import android.support.v7.widget.RecyclerView;
import android.view.View;
import android.view.ViewGroup;
import android.widget.TextView;

import com.jwthhealth_pub.R;
import com.jwthhealth_pub.old.report.view.SportDetailExplActivity;

import java.util.List;

/**
 * Created by liuzhen on 2017/11/1.
 */

public class DetailDescAdapter extends RecyclerView.Adapter {
    private final SportDetailExplActivity mActivity;
    private final List<String> mData;

    public DetailDescAdapter(SportDetailExplActivity sportDetailExplActivity, List<String> sport_desc) {
        this.mActivity = sportDetailExplActivity;
        this.mData = sport_desc;
    }

    @Override
    public RecyclerView.ViewHolder onCreateViewHolder(ViewGroup parent, int viewType) {
        return new ViewHolder(View.inflate(mActivity, R.layout.item_sport_detail_desc, null));
    }

    @Override
    public void onBindViewHolder(RecyclerView.ViewHolder holder, int position) {
        ViewHolder vh = (ViewHolder) holder;
        if (mData.get(position) != null)
            vh.desc.setText(mData.get(position));
    }

    @Override
    public int getItemCount() {
        return mData.size();
    }

    private class ViewHolder extends RecyclerView.ViewHolder {

        TextView desc;

        public ViewHolder(View itemView) {
            super(itemView);
            desc = itemView.findViewById(R.id.desc);
        }
    }
}
